package io.file;

import java.io.File;
import java.util.HashMap;
import java.util.Objects;

public class Test6 {
    private static final HashMap<String,Integer> countMap = new HashMap<>();
    public static void main(String[] args) {
        File file = new File("E:\\Project-IDEA\\Study_java");
        show(file);
        System.out.println(countMap);
    }

    private static void show(File file) {
        File[] files = file.listFiles();
        for (File path : Objects.requireNonNull(files)) {
            if (path.isDirectory()) {
                show(path);
            } else {
                String[] strs = path.getName().split("\\.");
                String s = strs[strs.length - 1];
                if (countMap.containsKey(s)) {
                    countMap.put(s,countMap.get(s) + 1);
                } else {
                    countMap.put(s,1);
                }
            }
        }
    }
}
